<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
if(!isset($_SESSION['db'])){
	$addressbrowser = $_SERVER['SERVER_NAME'];
	$temp = explode(".", $addressbrowser);
	$connection = mysql_connect("1.234.53.52", "cam", "5678" ) ;
	//$connection = mysql_connect("localhost", "root", "root" ) ;
	mysql_select_db("elihan", $connection);
	mysql_query("set names 'utf8'");
	$selectdatabase = mysql_query("SELECT am.DatabaseName,am.Logo from ac_eli_manager am where am.KeyName='$temp[0]' and am.`Status` = 2");
	$result = mysql_fetch_assoc($selectdatabase);

	$_SESSION['Logo']=$result[Logo];
		
	$_SESSION['db']= $result[DatabaseName];
	mysql_close($connection);
}
$database = $_SESSION['db'];
$connectadmin = mysql_connect("1.234.53.52", "cam", "5678") or die("Không kết nối được database");
//$connectadmin = mysql_connect("localhost", "root", "root") or die("Không kết nối được database");
mysql_select_db("elihan", $connectadmin);
mysql_query("set names 'utf8'");

$selectprofilecomp = mysql_query("SELECT eli.PartnerName, eli.Address,eli.BusinessNumber, eli.CorporateNumber
		 FROM ac_eli_manager eli where eli.DatabaseName='$database'");

$row = mysql_fetch_assoc($selectprofilecomp);
mysql_close($connectadmin);
?>
<?php
include '../../operations/connection.php';

$idempcerficates = $_REQUEST['idempcerficates'];
function getlang(){
		$lang = $_SESSION['lang'];
		
		if (empty($lang) || $lang == "EN") {
			$value = "../../value/value_en.php";
		} else if($lang == "VN") {
			$value = "../../value/value_vn.php";
		}
		else {
			$value = "../../value/value_kr.php";
		}
		return $value;
	}
	$value = getlang();
	include($value);
$lang=$_SESSION['lang'];
$selectempcertifi = mysql_query("SELECT e.FullName, e.CMND,e.Address,e.Position,e.CurrentJob,
		DATE_FORMAT(e.StartDate,'%Y-%m-%d') as StartDate,DATE_FORMAT(e.EndDate,'%Y-%m-%d') as EndDate,dl.DepartmentName  
		FROM employee e,department_lang dl ,department dp 
		WHERE e.IDDepartment = dl.IDDepartment AND dp.IDDepartment = dl.IDDepartment AND dl.LangID ='$lang'
		AND e.IDEmployee = '$idempcerficates'");


$resultemp = mysql_fetch_assoc($selectempcertifi);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Print</title>
<style>

.credential-form{width: 700px;border:2px solid #333;font-size: 15px;font-family: Cambrian; }
.credential-form-title{margin:50px 0;font-family: Cambrian;font-size: 25px;font-weight: bold;letter-spacing: 2px;text-align: center;padding: 10px;text-transform: uppercase;}
.credential-form-table{width: 90%;padding: 10px;height: 300px;border: 1px solid #333;margin: auto auto 50px;border-collapse: collapse;}
.credential-form-table tr td{ padding: 5px;text-align: center;}
.credential-form-info{text-align: center;margin-bottom: 80px}
.credential-form-info span{display: block;}
</style>
</head>

<body onload="window.print();" >
<div class="credential-form" style="text-align: center;margin-left: 25%">
		<div class="credential-form-title"><?php echo $l_emplcertifi?></div>
		
		<table class="credential-form-table" border="1" width="90%">
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_fullname?></b></td>
				<td><?php echo $resultemp[FullName]?></td>
				<td bgcolor="#EEEEEE"><b><?php echo $l_responsibilities?></b></td>
				<td><?php echo $resultemp[CurrentJob]?></td>
			</tr>
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_cmnd?></b></td>
				<td colspan="3"><?php echo $resultemp[CMND]?></td>
			</tr>
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_dept?></b></td>
				<td><?php echo $resultemp[DepartmentName]?></td>
				<td bgcolor="#EEEEEE"><b><?php echo $l_office?></b></td>
				<td><?php echo $resultemp[Position]?></td>
			</tr>
			<tr>
				<td bgcolor="#EEEEEE"><b><?php echo $l_timework?></b></td>
				<td colspan="2">
				<span style="margin-right: 5px"><?php echo $l_startwork?></span>
				 <span style="margin-right: 10px"><?php echo $l_from?></span>
				 <span id="dateFrom">
				 <?php if ($lang=="EN"){echo $resultemp[StartDate];}
					 else if($lang=="VN"){
					 	$day = date('d',strtotime($resultemp[StartDate]));$month = date('m',strtotime($resultemp[StartDate]));$year=date('Y',strtotime($resultemp[StartDate]));
						 echo "Ngày ".$day." Tháng ".$month." Năm ".$year;}
					 else if($lang=="KR"){
					 	$day = date('d',strtotime($resultemp[StartDate]));$month = date('m',strtotime($resultemp[StartDate]));$year=date('Y',strtotime($resultemp[StartDate]));
					 	echo $year." 년  ".$month." 월  ".$day." 일";
					 }
				  ?></span>
					<br /> <br /> 
				<span style="margin-right: 5px"><?php echo $l_totoday?></span> <span
					style="margin-right: 10px"><?php echo ""?></span>
					<span id="dateTo"><?php  if ($lang=="EN"){ echo $resultemp[EndDate];}
					 else if($lang=="VN"){
					 	$day = date('d',strtotime($resultemp[EndDate]));$month = date('m',strtotime($resultemp[EndDate]));$year=date('Y',strtotime($resultemp[EndDate]));
						 echo "Ngày ".$day." Tháng ".$month." Năm ".$year;}
					 else if($lang=="KR"){
					 	$day = date('d',strtotime($resultemp[EndDate]));$month = date('m',strtotime($resultemp[EndDate]));$year=date('Y',strtotime($resultemp[EndDate]));
					 	echo $year." 년  ".$month." 월  ".$day." 일";
					 }
					?></span>
					<br /> <br /> 
				<span style="font-size: 15px;" id="date"></span>
				</td>
				<td><?php echo "";?></td>
			</tr>
		</table>

		<div class="credential-form-info">
			<br /> <span style="font-size: 14px; font-weight: bold;"><?php echo $l_certifiabove?></span> <span
				style="font-size: 15px; margin: 80px 0px 0px 0px" id="date2">
				<?php if ($lang=="EN"){$datetime = date('Y-m-d') ;echo $datetime;}
					else if($lang=="VN"){$day = date('d');$month = date('m');$year=date('Y');
						echo "Ngày ".$day." Tháng ".$month." Năm ".$year;}
					else if($lang=="KR"){$day = date('d');$month = date('m');$year=date('Y'); 
						echo $year." 년  ".$month." 월  ".$day." 일";}
				?>
				</span>
			<div
				style="font-size: 16px; text-transform: uppercase; margin: 80px 0px 0px 0px"
				align="center">
				<span style="width: 220px;"><?php echo $row[Address]?></span>
			</div>
			<div
				style="font-size: 16px; font-weight: bold; text-transform: uppercase; margin: 10px 0px 0px 0px">
				<?php echo $row[PartnerName]?></div>
		</div>
	</div>

</body>
</html>